import { getDefaultFields } from '../utils';

module.exports = app => {
	const DataTypes = app.Sequelize;

	const Model = app.model.define('order_address', {
		id: {
			type: DataTypes.INTEGER(8).UNSIGNED,
			allowNull: false,
			primaryKey: true,
			autoIncrement: true
		},
		order_id: {
			type: DataTypes.STRING(100),
			allowNull: false,
			defaultValue: '0'
		},
		// 收货人姓名
		name: {
			type: DataTypes.STRING(50),
			allowNull: false,
			defaultValue: '',
		},
		// 手机号
		mobile: {
			type: DataTypes.STRING(60),
			allowNull: false,
			defaultValue: '',
		},
		// 地址名称-eg-天府软件园
		address_name: {
			type: DataTypes.STRING(120),
			allowNull: false,
			defaultValue: '',
		},
		// 详细地址-eg-天府大道一号
		address_detail: {
			type: DataTypes.STRING(120),
			allowNull: false,
			defaultValue: '',
		},
		// 地址详细描述-eg-c区3-11.
		address_description: {
			type: DataTypes.STRING(120),
			allowNull: false,
			defaultValue: '',
		},
		...getDefaultFields()
	}, {
		tableName: 'order_address',
		timestamps: false
	});


	Model.sync({ alter: true });

	Model.associate = function () {
	}

	return Model;
};
